package com.liyujie.dyeingmachine.ui.home.operate;

import androidx.lifecycle.ViewModel;

import com.blankj.utilcode.util.ActivityUtils;
import com.liyujie.dyeingmachine.mobile.dao.ReagentEntityDao;
import com.liyujie.dyeingmachine.mobile.entity.ReagentEntity;
import com.liyujie.dyeingmachine.mobile.event.MessageEvent;
import com.liyujie.dyeingmachine.mobile.event.MessageType;
import com.liyujie.dyeingmachine.pop.AddReagentPopup;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupAnimation;
import com.lxj.xpopup.interfaces.OnConfirmListener;

import org.greenrobot.eventbus.EventBus;

public class ReagentViewModel extends ViewModel {

    /**
     * 添加试剂
     */
    public void ReagentAddition() {
        AddReagentPopup mAddReagentPopup = new AddReagentPopup(ActivityUtils.getTopActivity());
        new XPopup.Builder(ActivityUtils.getTopActivity())
                .popupAnimation(PopupAnimation.ScaleAlphaFromCenter)
                .asCustom(mAddReagentPopup)
                .show();
    }


    /**
     * 修改试剂
     */
    public void ModifiedReagent(ReagentEntity mReagentEntity) {
        AddReagentPopup mAddReagentPopup = new AddReagentPopup(ActivityUtils.getTopActivity(), mReagentEntity);
        new XPopup.Builder(ActivityUtils.getTopActivity())
                .popupAnimation(PopupAnimation.ScaleAlphaFromCenter)
                .asCustom(mAddReagentPopup)
                .show();
    }

    /**
     * 清理数据
     */
    public void ClearData() {
        new XPopup.Builder(ActivityUtils.getTopActivity())
                .asConfirm("提示", "确认要清理所有数据吗？", new OnConfirmListener() {
                    @Override
                    public void onConfirm() {
                        /**
                         * 删除所有数据
                         */
                        ReagentEntityDao.getInstance().CleanAllData();
                        /**
                         * 刷新页面
                         */
                        EventBus.getDefault().post(new MessageEvent(MessageType.OPEN_SUCCESSFILLY));

                    }
                })
                .show();
    }

    /**
     * 染色方案
     */
    public void DyeingScheme() {

    }


    /**
     * 位置设置
     */
    public void LocationSetting() {

    }

    /**
     * 开始染色
     */
    public void StartDyeing() {

    }

    /**
     * 温控设置
     */
    public void TemperatureControlSetting() {

    }


    /**
     * 时间设置
     */
    public void TimeSetting() {

    }


    /**
     * 关于设备
     */
    public void AboutEquipment() {

    }

    /**
     * 返回按键
     */
    public void BackKey() {
        /**
         * 结束页面
         */
        ActivityUtils.finishActivity(ReagentActivity.class);
    }


}
